package tag27_18_08.streams;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;

public class St04_LesenSchreibenMitEinemHilfsarray {

	public static void main(String[] args) throws IOException {
		
//		Reader in = new FileReader("manuell.txt");
//		
//		char[] cbuf = new char[1024];
//		
//		while(true){
//			int len = in.read(cbuf);
//			System.out.println("gelesen " + len + " Zeichen");
//			
//			if(len == -1)
//				break;
//			
//			String nexStr = String.valueOf(cbuf, 0, len);
//			
//			System.out.println(nexStr);
//		}
		
		
		//Ahora leer y escribir juntos
		Reader in = new FileReader("manuell.txt");
		Writer out = new FileWriter("copy.txt"); 

		char[] cbuf = new char[1024];
		
		int len;
		while((len = in.read(cbuf)) !=-1){
			System.out.println("gelesen " + len + " Zeichen");
			out.write(cbuf, 0, len);
			String nexStr = String.valueOf(cbuf, 0, len);
			System.out.println(nexStr);
		}
		in.close();
		out.close();
		
	} // end of main

}
